#pragma once
#include <QThread>
#include <mutex>
#include <list>
#include "XDecodeThread.h"
class XAudioPlay;
class XResample;
struct AVCodecParameters;
class XAudioThread:public XDecodeThread
{
public:
	//不管成功与否都清理
	//当前播放音频的pts

	long long pts = 0;
	virtual bool Open(AVCodecParameters *para, int sampleRate, int channels);
	//停止线程，清理资源
	virtual void Close();
	virtual void Clear();
	void run();
	XAudioThread();
	virtual ~XAudioThread();
	void SetPause(bool isPause);
	bool Pause = false;
protected:
	std::mutex audiomux;
	XAudioPlay *ap = 0;
	XResample *res = 0;
};

